package datasv.collegeQuery_datasv;

import java.rmi.RemoteException;
import java.util.ArrayList;
import java.util.List;

import data.datafactory.DatabaseOperator;
import datasv.studentQuery_datasv.StudentQueryDatasvController;
import datasv.teacherQuery_datasv.TeacherQueryDatasvController;
import po.CollegeStudentListPO;
import po.StudentPO;
import po.TeacherPO;

public class GetStudentPOList {
	public static void main(String[] args) {
		System.out.println(new GetStudentPOList().getStudentList("001"));
	}
	public List<StudentPO> getStudentList(String collegeID){
		return getInSql(collegeID);
	}
	public  List<StudentPO> getInSql(String collegeID){
		ArrayList<StudentPO> list=new ArrayList<StudentPO>();
		DatabaseOperator op=new DatabaseOperator("college");
		if(!op.ifIDExist("college_list", collegeID)){
			return list;
		}
		ArrayList<String> id=op.getColumn("student_list", "id");
		for (int i = 0; i < id.size(); i++) {
			if(id.get(i).substring(0, 3).equals(collegeID)){
				try {
					list.add(new StudentQueryDatasvController().getStudent(id.get(i)));
				} catch (RemoteException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
			}
		}
		return list;
	}
}
